
package com.nhc.activity_fragment;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;
import android.content.Intent;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.support.v4.app.Fragment;
import android.view.KeyEvent;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.LinearLayout;

import com.astrob.activitys.GPSProvider;
import com.astrob.activitys.PositionProvider;
import com.astrob.model.LonLat;
import com.astrob.model.Msg;
import com.astrob.naviframe.Start;
import com.astrob.nhcmap.R;
import com.astrob.util.CrashHandler;
import com.astrob.util.SysUtils;
import com.astrob.util.Utils;
import com.astrob.version.UpdateManager;
import com.nhc.database.dbmodel.WayPoint;
import com.nhc.database.manager.DBDataCenter;
import com.nhc.database.manager.IECenter;
import com.nhc.database.manager.QiyaCenter;
import com.nhc.model.CoordParmFileHandle;
import com.nhc.model.NaviTrackSetInfo;
import com.nhc.model.PoiCollectInfo;
import com.nhc.model.TripDataFileHandle;
import com.nhc.model.VCodeFileHandle;
import com.nhc.srtm.SrtmService;
import com.nhc.srtm.SrtmTile;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import zuo.biao.library.base.BaseBottomTabActivity;
import zuo.biao.library.interfaces.OnBottomDragListener;
import zuo.biao.library.ui.AlertDialog;
import zuo.biao.library.util.Log;


public class MainTabActivity extends BaseBottomTabActivity implements OnBottomDragListener, AlertDialog.OnDialogButtonClickListener {
    private final String TAG = "MainTabActivity";

    static final String INTENT_DATA_FILEPATH = "INTENT_DATA_FILEPATH";
    //启动方法<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    /**
     * 启动这个Activity的Intent
     *
     * @param context
     * @return
     */

    public static Intent createIntent(Context context, String strFilePath) {
        return new Intent(context, MainTabActivity.class)
                .putExtra(INTENT_DATA_FILEPATH, strFilePath);
    }
    //启动方法>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    @Override
    public Activity getActivity() {
        return this;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        if (SysUtils.getInstance().is240x320) {
            setContentView(R.layout.main_tab_240x320_activity, this);
        } else {
            setContentView(R.layout.main_tab_activity, this);
        }

//        getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

        CrashHandler crashHandler = CrashHandler.getInstance();
        crashHandler.init(getApplicationContext());
        Thread.setDefaultUncaughtExceptionHandler(crashHandler);

        //功能归类分区方法，必须调用<<<<<<<<<<
        initView();
        initData();
        initEvent();
        //功能归类分区方法，必须调用>>>>>>>>>>

        PositionProvider.getInstance().init(this, null);

//        String a = Utils.getDirName(45);

        Log.e("BHCnav","Test  10");

        IECenter.getInstance().init(this);
//        IECenter.getInstance().importGPX("");
//        IECenter.getInstance().importKML("");
        checkVersion();

        //apk版本升级
        UpdateManager.getUpdateManager().checkAppUpdate(this, false);

        Log.e("BHCnav","Test  11");
        //Mapsforge 加载需要
//        MapsForgeTileSource.createInstance(getApplication());
        SysUtils.getInstance().loadeMapSource();//Mapsforge mapfile加载

        int240x320();
        Log.e("BHCnav","Test  12");

        intent = getIntent();
        final String strFilePath = intent.getStringExtra(INTENT_DATA_FILEPATH);
        if (strFilePath != null && strFilePath.length() > 1) {
            addGPXKML2DB(strFilePath);
        }


//        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//        long aa = System.currentTimeMillis();
//        long bb = Utils.getTimesnight();
//
//        Date curDate0 = new Date(aa);
//        String strDate0 = formatter.format(curDate0);
//
//        Date curDate1 = new Date(bb);
//        String strDate1 = formatter.format(curDate1);

//        aa = 0;
    }

    private void addGPXKML2DB(final String filePath) {
        showShortToast(filePath);
        showProgressDialog(R.string.loading);
        runThread(TAG + "initData", new Runnable() {
            @Override
            public void run() {
                if (filePath.contains(".gpx")) {
                    IECenter.getInstance().importGPX(filePath);
                } else if (filePath.contains(".KML") || filePath.contains(".kml")) {
                    IECenter.getInstance().importKML(filePath);
                } else if (filePath.contains(".kmz") || filePath.contains(".KMZ")) {
                    IECenter.getInstance().importKMZ(filePath);
                }
                runUiThread(new Runnable() {
                    @Override
                    public void run() {
                        dismissProgressDialog();
                        showShortToast(getString(R.string.daoru_toast_2));
                    }
                });
            }
        });
    }

    void int240x320() {
        if (!SysUtils.getInstance().is240x320) {
            return;
        }
//        FY app需将GPX、KML、相册文件夹放置在设备内存根目录；
        File file0 = new File(Environment.getExternalStorageDirectory() + "/GPX");
        if (!file0.exists()) {
            file0.mkdir();
        }
        File file1 = new File(Environment.getExternalStorageDirectory() + "/KML");
        if (!file1.exists()) {
            file1.mkdir();
        }
//        File file2 = new File(Environment.getExternalStorageDirectory() + "/PIC");
//        if (!file2.exists()) {
//            file2.mkdir();
//        }

        new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    mHandler.sendEmptyMessage(Msg.REFRESH_GPSSTATUS);
                }
            }
        }).start();
    }

    private final static int NOTIFICATION_ID_ICON = 0x10000;

    void refreshGPSState() {
        if (!SysUtils.getInstance().is240x320) {
            return;
        }

        float gpsAccuracy = 0;
        GPSProvider mGpsProvider = GPSProvider.getInstance();
        String strAccuracy = "未定位";
        int icon = R.drawable.ic_qs_signal_0;
        if (mGpsProvider != null && mGpsProvider.isFixed()) {
            gpsAccuracy = mGpsProvider.getAccuracy();
            if (gpsAccuracy < 100) {
                String SS[] = SysUtils.getInstance().getAltitudeStr(mGpsProvider.getAccuracy());
                strAccuracy = SS[0] + SS[1];
            }
            if (gpsAccuracy < 10) {
                icon = R.drawable.ic_qs_signal_4;
            } else if (gpsAccuracy < 20) {
                icon = R.drawable.ic_qs_signal_3;
            } else if (gpsAccuracy < 30) {
                icon = R.drawable.ic_qs_signal_2;
            } else {
                icon = R.drawable.ic_qs_signal_1;
            }
        }

        try {
            NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
            Notification noti = null;//创建Notification
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
                noti = new Notification.Builder(this)//实例化Builder
                        .setTicker("GPS")//在状态栏显示的标题
                        .setContentTitle("GPS定位状态")//设置标题
                        .setContentText(strAccuracy)//设置内容
                        .setSmallIcon(icon)//设置状态栏显示时的图标
                        .setLargeIcon(BitmapFactory.decodeResource(getResources(), icon))
//                    .setDeleteIntent(PendingIntent.getActivity(this, 0, getIntent(), 0))//设置删除时的意图
                        .setAutoCancel(false)//设置是否自动按下过后取消
                        .setOngoing(true)//设置为true时就不能删除  除非使用notificationManager.cancel(1)方法
                        .build();
                nm.notify(NOTIFICATION_ID_ICON, noti);//管理器通知
            }
        } catch (Exception e) {

        }

    }

    private void checkVersion() {
        int rightState = VCodeFileHandle.getInstance().getRightState();
        switch (rightState) {
            default:
                break;
            case 1:
                showShortToast(getString(R.string.csbysq));
                break;
            case -2:
                showShortToast(getString(R.string.nodeviceid));
                break;
            case -1:
                //无试用期
                new AlertDialog(context, getString(R.string.wxts), getString(R.string.nygydsyqydqgmzbddt), true, 1, this).show();
                break;
            case 0:
                //试用期内
                showShortToast(getString(R.string.csbmysqnyygydsyq));
                break;
        }
//        GeoHash.test();
//        SrtmService.getInstance().scanDirectory(Start.RUNDIR + "/SRTM/");
//        testSRTM3();

    }


    void testSRTM() {
        SrtmTile srtmTile = new SrtmTile(new File(Start.RUNDIR + "/N27E120.hgt"));
        double lon = 120;
        double lat = 27;
        double ele = 0;
        ArrayList<Double> eleList = new ArrayList<Double>();
        int range = 100;
        for (int i = 0; i < range; i++) {
            for (int j = 0; j < range; j++) {
                if (srtmTile.hasData(lon, lat)) {
                    ele = srtmTile.getElevation(lon, lat);
                    eleList.add(ele);
                }
                lat += 0.01;
            }
            lon += 0.01;
            lat = 27;
        }

        int size = eleList.size();
    }

    void testSRTM2() {
        SrtmService.getInstance().scanDirectory(Start.RUNDIR + "/SRTM/");
        double lon = 120;
        double lat = 27;
        double ele = 0;
        ArrayList<Double> eleList = new ArrayList<Double>();
        int range = 100;
        for (int i = 0; i < range; i++) {
            for (int j = 0; j < range; j++) {
                ele = SrtmService.getInstance().getElevation(lon, lat);
                if (ele != SrtmService.ERROR_ELE) {
                    eleList.add(ele);
                }

                lat += 0.01;
            }
            lon += 0.01;
            lat = 27;
        }

        ele = SrtmService.getInstance().getElevation(121, lat);
        int size = eleList.size();
    }

    void testSRTM3() {
        SrtmService.getInstance().scanDirectory(Start.RUNDIR);
        double lon = 120;
        double lat = 27;
        double ele = 0;
        ArrayList<Double> eleList = new ArrayList<Double>();
        int range = 3;
        double base = 0.0001;//10米- 最低的--- 1文件约有100w个数据
        for (int i = 0; i < range; i++) {
            lat = 27 + base;
            lon = 120 + base;
            base *= 10;

            ele = SrtmService.getInstance().getElevation(lon, lat);
            if (ele != SrtmService.ERROR_ELE) {
                eleList.add(ele);
            }
        }

        int size = eleList.size();
    }

    // UI显示区(操作UI，但不存在数据获取或处理代码，也不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    LinearLayout llBottomTab;

    @Override
    public void initView() {// 必须调用
        super.initView();
        exitAnim = R.anim.bottom_push_out;
        llBottomTab = (LinearLayout) findViewById(R.id.llBottomTab);
    }

    @Override
    protected int[] getTabClickIds() {
        return new int[]{R.id.llBottomTabTab0, R.id.llBottomTabTab1, R.id.llBottomTabTab2, R.id.llBottomTabTab3, R.id.llBottomTabTab4};
    }

    @Override
    protected int[][] getTabSelectIds() {
        return new int[][]{
                new int[]{R.id.ivBottomTabTab0, R.id.ivBottomTabTab1, R.id.ivBottomTabTab2, R.id.ivBottomTabTab3, R.id.ivBottomTabTab4},//顶部图标
                new int[]{R.id.tvBottomTabTab0, R.id.tvBottomTabTab1, R.id.tvBottomTabTab2, R.id.tvBottomTabTab3, R.id.tvBottomTabTab4}//底部文字
        };
    }

    @Override
    public int getFragmentContainerResId() {
        return R.id.flMainTabFragmentContainer;
    }

    MainMapFragment _mainMapFragment;
    MoreFragment _moreFragment;
    TripFragment _tripFragment;
    CompassFragment _compassFragment;
    SatelliteFragment _satelliteFragment;

    @Override
    protected Fragment getFragment(int position) {
        if (_tripFragment == null) {
            _tripFragment = TripFragment.createInstance();
        }
        if (_satelliteFragment == null) {
            _satelliteFragment = SatelliteFragment.createInstance();
        }
        if (_compassFragment == null) {
            _compassFragment = CompassFragment.createInstance();
        }
        if (_moreFragment == null) {
            _moreFragment = MoreFragment.createInstance();
            _moreFragment.setFatherHandler(mHandler);
        }
        if (_mainMapFragment == null) {
            _mainMapFragment = MainMapFragment.createInstance();
            _mainMapFragment.setFatherHandler(mHandler);
            mapHandler = _mainMapFragment.getHandler();
        }
        switch (position) {
            case 1:
                return _tripFragment;
            case 2:
                return _satelliteFragment;
            case 3:
                return _compassFragment;
            case 4: {
                return _moreFragment;
            }
            default: {
                return _mainMapFragment;
            }
        }
    }

    Handler mapHandler;

    @Override
    protected void selectTab(int position) {
        //导致切换时闪屏，建议去掉BottomTabActivity中的topbar，在fragment中显示topbar
        if (Utils.isFastDoubleClick())
            return;

        String[] TAB_NAMES = getResources().getStringArray(R.array.tab_names);
        tvBaseTitle.setText(TAB_NAMES[position]);

        //点击底部tab切换顶部tab，非必要
//        if (position == 2 && position == currentPosition && demoTabFragment != null) {
//            demoTabFragment.selectNext();
//        }
    }
    // UI显示区(操作UI，但不存在数据获取或处理代码，也不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


    // Data数据区(存在数据获取或处理代码，但不存在事件监听代码)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    @Override
    public void initData() {// 必须调用
        super.initData();
    }
    // Data数据区(存在数据获取或处理代码，但不存在事件监听代码)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    public void naviToNavipt() {
        if (_tripFragment == null) {
            return;
        }
        selectFragment(0);
    }

    public void naviByRoute() {
        if (_tripFragment == null) {
            return;
        }
        selectFragment(0);
    }

    // Event事件区(只要存在事件监听代码就是)<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    @Override
    public void initEvent() {// 必须调用
        super.initEvent();

    }

    @Override
    public void onDragBottom(boolean rightToLeft) {
        //将Activity的onDragBottom事件传递到Fragment，非必要<<<<<<<<<<<<<<<<<<<<<<<<<<<
        switch (currentPosition) {
            case 2:
                break;
            default:
                break;
        }
        //将Activity的onDragBottom事件传递到Fragment，非必要>>>>>>>>>>>>>>>>>>>>>>>>>>>
    }

    // 系统自带监听方法<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    //双击手机返回键退出<<<<<<<<<<<<<<<<<<<<<
    private long firstTime = 0;//第一次返回按钮计时

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (currentPosition == 0 && !_mainMapFragment.isShownPopMenu()) {
            switch (keyCode) {
                default:
                    break;
                case 21://left
                    doKeyLeft();
                    return true;
                case 22://right
                    doKeyRight();
                    return true;
                case 19://up
                    doKeyUp();
                    return true;
                case 20://down
                    doKeyDown();
                    return true;
            }
        }

        return super.onKeyDown(keyCode, event);
    }

    //长按的方式
//    https://blog.csdn.net/zhanghaikuan/article/details/50639429
    @Override
    public boolean onKeyUp(int keyCode, KeyEvent event) {

        if (currentPosition == 4) {
            _moreFragment.doKeyUp();
        } else if (currentPosition == 1) {
            _tripFragment.setFoucseCtrl();
        } else if (currentPosition == 3) {
            _compassFragment.setFoucseCtrl();
        }

        switch (keyCode) {
            case KeyEvent.KEYCODE_MENU:
                doMenu();
                break;
            case KeyEvent.KEYCODE_BACK:
                if (SysUtils.getInstance().is240x320) {
                    if (this.currentPosition == 0) {
                        if (_mainMapFragment.isShownPopMenu()) {
                            _mainMapFragment.doPopMenu(-1);
                            return true;
                        } else if (_mainMapFragment.mMapMode == 0) {
                            if (mapHandler != null) {
                                mapHandler.sendEmptyMessage(Msg.ONLOCAL);
                            }
                            return true;
                        }
                    }
                    int pos = this.currentPosition - 1;
                    if (pos < 0) {
                        pos = 4;
                    }
//                    doHideTab(false);
                    if (_tripFragment == null) {
                        return false;
                    }
                    selectFragment(pos);
                } else {
                    long secondTime = System.currentTimeMillis();
                    if (secondTime - firstTime > 2000) {
                        showShortToast(getString(R.string.texit));
                        firstTime = secondTime;
                    } else {//完全退出
                        TripDataFileHandle.getInstance().save();
                        CoordParmFileHandle.getInstance().save(this);
                        SysUtils.getInstance().saveMapSource();
                        moveTaskToBack(false);//应用退到后台
                        System.exit(0);
                    }
                }
                return true;
            case 229:
            case 249: //左边下面的按键
//                doHideTab();
                if (currentPosition == 0) {
                    mapHandler.sendEmptyMessage(Msg.ADDMARKERW);
                } else {
                    addMarker();
                }
                return true;
            case KeyEvent.KEYCODE_SEARCH://搜索
                toActivity(SearchTypeActivity.createIntentfromMore(this), 5);
                return true;
            case 21://left
                doKeyLeft();
                return true;
            case 22://right
                doKeyRight();
                return true;
            case 19://up
                doKeyUp();
                return true;
            case 20://down
                doKeyDown();
                return true;
            case 24://Zoomin
                if (!SysUtils.getInstance().is240x320) {
                    return true;
                }
                if (mapHandler != null) {
                    mapHandler.sendEmptyMessage(Msg.MAPZOOMIN);
                }
                return true;
            case 25://Zoomout
                if (!SysUtils.getInstance().is240x320) {
                    return true;
                }
                if (mapHandler != null) {
                    mapHandler.sendEmptyMessage(Msg.MAPZOOMOUT);
                }
                return true;
            case 23://ok
                doKeyOK();
                return true;
        }

//        return super.onKeyUp(keyCode, event);
        return true;
    }

    private void doMenu() {
        if (currentPosition == 0) {
            _mainMapFragment.onPopMenu();
        } else if (currentPosition == 1) {
            _tripFragment.onPopMenu();
        }
    }

    private void doKeyOK() {
        if (currentPosition == 0) {
            if (!_mainMapFragment.isShownPopMenu()) {
                if (mapHandler != null) {
                    mapHandler.sendEmptyMessage(Msg.NAVI2TIP);
                }
            }
        }

    }

    private void doKeyDown() {
        if (currentPosition == 0) {
            if (!_mainMapFragment.isShownPopMenu()) {
                if (mapHandler != null) {
                    mapHandler.sendEmptyMessage(Msg.MAPDOWN);
                }
            }
        }
    }

    private void doKeyUp() {
        if (currentPosition == 0) {
            if (!_mainMapFragment.isShownPopMenu()) {
                if (mapHandler != null) {
                    mapHandler.sendEmptyMessage(Msg.MAPUP);
                }
            }
        }
    }

    private void doKeyRight() {
        if (currentPosition == 0) {
            if (!_mainMapFragment.isShownPopMenu()) {
                if (mapHandler != null) {
                    mapHandler.sendEmptyMessage(Msg.MAPRIGHT);
                }
            }
        }
    }

    private void doKeyLeft() {
        if (currentPosition == 0) {
            if (!_mainMapFragment.isShownPopMenu()) {
                if (mapHandler != null) {
                    mapHandler.sendEmptyMessage(Msg.MAPLEFT);
                }
            }
        }
    }

    private void addMarker() {
//        if (this.currentPosition != 0) {
//            return;
//        }
        LonLat ll = SysUtils.getInstance().getLL();
        WayPoint wp = DBDataCenter.getInstance().createNewWayPoint(ll);
        wp.setAltitude(GPSProvider.getInstance().getAltitude());
        if (NaviTrackSetInfo.getInstance().isUseqiyagd() && QiyaCenter.getInstance()._thisQiyaInfo != null) {
            double qiyaH = QiyaCenter.getInstance()._thisQiyaInfo.getAltitude();
            double H = wp.getAltitude();
            if (Math.abs((int) (qiyaH - H)) < 100 || H == 0) {
                //气压高度误差太大；可能气压高度是不准确的则不用
                wp.setAltitude(qiyaH);
            }
        }

        if (PoiCollectInfo.getInstance().getSavemode() == 0) {
            DBDataCenter.getInstance().saveWayPoint(wp);
            showShortToast(getString(R.string.tsavenpt));
        } else {
            DBDataCenter.getInstance().makerEdit = wp;
            toActivity(MarkerPointActivity.createIntent(this));
        }

        if (mapHandler != null) {
            mapHandler.sendEmptyMessage(Msg.UPDATEMAP);
        }
    }

    @SuppressLint("HandlerLeak")
    private Handler mHandler = new Handler() {
        @Override
        public void handleMessage(android.os.Message msg) {
            switch (msg.what) {
                case Msg.DOAUTOTAB:
                    doAutoTab();
                    break;
                case Msg.DOSHOWTAB:
                    doHideTab(false);
                    break;
                case Msg.DOHIDETAB:
                    doHideTab(true);
                    break;
                case Msg.NAVI_TO_DEST:
                    naviToNavipt();
                    break;
                case Msg.NAVI_BY_ROUTE:
                    naviByRoute();
                    break;
                case Msg.REFRESH_GPSSTATUS:
                    refreshGPSState();
                    break;
            }
        }
    };

    boolean isHideTab = false;

    void doAutoTab() {
        isHideTab = !isHideTab;
        doHideTab(isHideTab);
    }

    void doHideTab(boolean isHide) {
        isHideTab = isHide;
        if (isHideTab) {
            llBottomTab.setVisibility(View.GONE);
        } else {
            llBottomTab.setVisibility(View.VISIBLE);
        }
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (event.getAction() == MotionEvent.ACTION_DOWN) {

        }
        return false;
    }

    @Override
    public void onDialogButtonClick(int requestCode, boolean isPositive) {

        if (requestCode == 1) {
            if (isPositive == false) {
                moveTaskToBack(false);//应用退到后台
                System.exit(0);
            } else {
                toActivity(AboutActivity.createIntent(this), REQUEST_CODE_ABOUT);
            }

        }
    }

    public static final int REQUEST_CODE_ABOUT = 18;

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {

        if (resultCode == 2607) {
            addMarker();
            return;
        } else if (resultCode == 3002) {
            toActivity(SearchTypeActivity.createIntentfromMore(this), 5);
            return;
        }

        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == REQUEST_CODE_ABOUT) {
            checkVersion();
            return;
        }

    }

    // 类相关监听<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<


    // 类相关监听>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    // 系统自带监听方法>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    // Event事件区(只要存在事件监听代码就是)>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

}